home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr30 / hercb21.zip / HERCBIOS.DOC < prev    next >
Text File  |  1993-05-03  |  21KB  |  595 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.                             *****   _H_E_R_C_B_I_O_S   *****
  7.                     _B_I_O_S _E_N_H_A_N_C_E_M_E_N_T _F_O_R _T_H_E _H_E_R_C_U_L_E_S _B_O_A_R_D
  8.  
  9.                          Copyright  Dave Tutelman  1988
  10.                               All Rights Reserved
  11.  
  12.  
  13.  
  14.                                David M. Tutelman
  15.                                 16 Tilton Drive
  16.                                Wayside, NJ 07712
  17.  
  18.                                 (201) 922 - 9576
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.                                     CONTENTS
  27.  
  28.                       1. GETTING STARTED
  29.  
  30.  
  31.                       2. USING HERCBIOS FOR CGA EMULATION
  32.                            2.1. What Programs Work?
  33.                            2.2. Tuning for Performance
  34.  
  35.  
  36.                       3. HERCULES BIOS PROGRAMMING
  37.                            3.1. Hercules Modes
  38.                            3.2. BIOS Functions
  39.                            3.3. What Languages Work?
  40.  
  41.  
  42.                       4. REGISTRATION & COPYING
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.        HERCBIOS 2.1                                             10-31-88
  64.  
  65.  
  66.  
  67.  
  68.  
  69.                                      - 2 -
  70.  
  71.  
  72.        The accompanying program is a front end to the INT 10 (VIDEO)
  73.        functions of the DOS BIOS, so that the important functions work
  74.        on a Hercules graphics board or its clones. It is a
  75.        terminate-and-stay-resident program, that is installed by being
  76.        called, say, from AUTOEXEC.BAT.
  77.  
  78.  
  79.        _1. _G_E_T_T_I_N_G _S_T_A_R_T_E_D
  80.  
  81.        This program has several uses:
  82.  
  83.             _E_m_u_l_a_t_i_o_n _o_f _t_h_e _C_G_A _b_o_a_r_d. There are many programs
  84.             available, especially games, that work with the IBM Color
  85.             Graphics Adapter but not with the Hercules. HERCBIOS
  86.             emulates the graphic modes 4, 5, and 6 of the CGA.
  87.  
  88.             _P_r_o_g_r_a_m_m_i_n_g _g_r_a_p_h_i_c_s _a_p_p_l_i_c_a_t_i_o_n_s for the Hercules board.
  89.             HERCBIOS provides you with the standard BIOS functions for
  90.             handling pixels that the normal BIOS provides for the CGA.
  91.             It also provides the character-handling BIOS functions. Thus
  92.             it's easy to mix graphics and text on the screen.
  93.  
  94.             _P_r_o_g_r_a_m_m_i_n_g _c_h_a_r_a_c_t_e_r _a_p_p_l_i_c_a_t_i_o_n_s _w_i_t_h _4_3 _l_i_n_e_s of
  95.             characters on the screen. HERCBIOS provides a mode in which
  96.             both graphics and small characters can be drawn.
  97.  
  98.        To install HERCBIOS on your machine, run it as a command with the
  99.        appropriate options:
  100.  
  101.  
  102.                HERCBIOS  [/Cn] [/Dn] [/Mnn]
  103.  
  104.  
  105.                        /Cn, /Dn   Tuning parameters for emulation
  106.                        /Mnn       Change the Hercules modes
  107.  
  108.  
  109.        The options are explained in the following sections. You can
  110.        include this line in your AUTOEXEC.BAT file, so that the BIOS is
  111.        installed whenever you boot your PC.
  112.  
  113.        You will want to check out your machine with HERCBIOS after you
  114.        install it. Do this by running TESTPIX.EXE (included in this
  115.        distribution), with the video mode as the command line argument.
  116.        (E.g.- TESTPIX 8 to use Hercules mode 8.) Within TESTPIX,
  117.        pressing "Return" after each screen is drawn will make the
  118.        program go on to the next step.
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.        HERCBIOS 2.1                                             10-31-88
  130.  
  131.  
  132.  
  133.  
  134.  
  135.                                      - 3 -
  136.  
  137.  
  138.        _2. _U_S_I_N_G _H_E_R_C_B_I_O_S _F_O_R _C_G_A _E_M_U_L_A_T_I_O_N
  139.  
  140.        HERCBIOS can run many graphics programs written for the CGA, even
  141.        some (not all) that don't use the BIOS for writing to the screen.
  142.        If the program uses the BIOS to set CGA graphics modes 4, 5, or
  143.        6, the BIOS set-mode call will turn on CGA emulation.
  144.  
  145.  
  146.        _2._1.  _W_h_a_t _P_r_o_g_r_a_m_s _W_o_r_k?
  147.  
  148.        Before the technical explanation, let's review a short list of
  149.        programs that are known either to work or not to work with
  150.        HERCBIOS.
  151.  
  152.             _W_i_l_l _W_o_r_k                          _W_o_n'_t _W_o_r_k
  153.             BASICA Graphics (Microsoft)        Jet (SubLogic)
  154.             Centipede (R.J.Grafe)              Mean 18 (Accolade)
  155.             PrintMaster                        Hopper
  156.             Tick Attack (Pegasus)              StarGate
  157.             Chess (Don Berg)                   Bricks (Vince Bly)
  158.             David's Kong                       Coins In A Box
  159.             Bert & the Snake (Piazza)          Astro (Digital Marketing)
  160.  
  161.        Even on those programs where it works, emulation still has its
  162.        limitations:
  163.  
  164.           - The aspect ratio of the screen is not as tall as it should
  165.             be; we're using only 200 scan lines of the 348 on the
  166.             Hercules screen.
  167.  
  168.           - Moving objects on the picture tends to "ghost" from one
  169.             place to another rather than "snap". It takes about a
  170.             quarter second for all the pixels of an object to move.
  171.             Tuning to improve the response is discussed in the next
  172.             section.
  173.  
  174.           - It takes processing to run the emulation, reducing the
  175.             real-time available for the program to do its work. Some
  176.             programs will therefore run noticeably slower.
  177.  
  178.        So what IS the criterion for whether a program will run under
  179.        emulation? It must not try to address the 6845 display controller
  180.        chip directly. It's all right for the program to access video RAM
  181.        directly, but the controller chip is off limits. Surprisingly,
  182.        about half the graphics programs I've tested seem to work,
  183.        indicating that they use the BIOS call to set the video mode and
  184.        don't check the retrace bit to avoid snow.
  185.  
  186.  
  187.        _2._2.  _T_u_n_i_n_g _f_o_r _P_e_r_f_o_r_m_a_n_c_e
  188.  
  189.        HERCBIOS accomplishes its emulation by refreshing the screen each
  190.        tick of the MS-DOS system clock (18.6 ticks per second). However,
  191.        it doesn't refresh all the pixels each tick; that would take more
  192.        than 100% of the processor's real time on a 4.77 MHz 8088.
  193.        Instead it refreshes about a quarter of the pixels each clock
  194.  
  195.        HERCBIOS 2.1                                             10-31-88
  196.  
  197.  
  198.  
  199.  
  200.  
  201.                                      - 4 -
  202.  
  203.  
  204.        tick. This divides the real time of a "vanilla" PC about half and
  205.        half between computing for the application and refreshing the
  206.        display. The result is a pair of visible performance
  207.        degradations: (1) the application runs at half speed, and (2) the
  208.        pixels of a moving object "ghost" after it, taking four ticks
  209.        (0.23 sec) to finish catching up with it.
  210.  
  211.        It is possible to balance the processing between display and
  212.        computing, by calling HERCBIOS with command line arguments. You
  213.        can allocate more time to computing (/Cn) or to display (/Dn), by
  214.        some factor (n).
  215.  
  216.          /_C_n - allocates more time to computing, by refreshing the
  217.             display only every nth clock tick (instead of every tick). n
  218.             can vary from 1 (the default) to 9. Example:  /C4 refreshes
  219.             the display every 4/18.6 of a second, and only a quarter of
  220.             the pixels each time.
  221.  
  222.          /_D_n - allocates more time to the display, by refreshing more
  223.             pixels each time refresh is done (normally every clock
  224.             tick). n can vary from 1 (the default) to 4. For n=4, all
  225.             the pixels are refreshed each tick. Example:  /D2 refreshes
  226.             half the pixels 18.6 times a second.
  227.  
  228.        If you aren't satisfied with the display performance on your
  229.        machine with your favorite programs, you should experiment with
  230.        different values of /C and /D. You don't need to reboot the
  231.        machine every time you change a tuning parameter; if HERCBIOS is
  232.        run again after it has already been installed, it will detect the
  233.        fact and just change the parameter value. That means that you
  234.        can, if you wish, use different tunings for different programs;
  235.        call the programs from a .BAT file that first calls HERCBIOS to
  236.        set the tuning values.
  237.  
  238.        It is possible to set BOTH /C and /D, though I haven't found any
  239.        practical use for it. For instance, /C9 /D4 would compute for
  240.        half a second without updating the display, then snap all the
  241.        pixels to the current value.
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.        HERCBIOS 2.1                                             10-31-88
  262.  
  263.  
  264.  
  265.  
  266.  
  267.                                      - 5 -
  268.  
  269.  
  270.        _3. _H_E_R_C_U_L_E_S _B_I_O_S _P_R_O_G_R_A_M_M_I_N_G
  271.  
  272.        HERCBIOS provides the programmer with most of the basic functions
  273.        one normally expects from a video BIOS. The only ones omitted
  274.        from the basic set (functions 0-15) are (1) set cursor size, (4)
  275.        get the light pen position, (8) read character and attribute from
  276.        screen, and (11) set color palette. Functions 1, 4, and 11 are
  277.        not relevant to the Hercules board, and function 8 is seldom used
  278.        and non-trivial to implement.
  279.  
  280.        HERCBIOS intercepts all calls to Interrupt 10h, the video BIOS
  281.        interrupt. It determines (in a minimum of machine cycles) whether
  282.        it needs to handle the call; if not, it passes control to the ROM
  283.        BIOS. Those cases it needs to handle are;
  284.  
  285.           - The current video mode is a native Hercules mode.
  286.  
  287.           - The function requested is 0 - Set video mode.
  288.  
  289.  
  290.  
  291.        _3._1. _H_e_r_c_u_l_e_s _M_o_d_e_s
  292.  
  293.        The graphics modes recognized and processed by HERCBIOS are:
  294.  
  295.           - _M_o_d_e _4 _o_r _5 - _C_G_A _m_e_d_i_u_m-_r_e_s _m_o_d_e: This invokes CGA
  296.             emulation, using a 640x200 portion of the 720x348 Hercules
  297.             raster to emulate the CGA board.
  298.  
  299.           - _M_o_d_e _6 - _C_G_A _h_i_g_h-_r_e_s _m_o_d_e: This too invokes CGA emulation,
  300.             using a 640x200 portion of the 720x348 Hercules raster to
  301.             emulate the CGA board.
  302.  
  303.           - _M_o_d_e _8 - _H_e_r_c_u_l_e_s _g_r_a_p_h_i_c_s _m_o_d_e: This uses the full
  304.             Hercules raster, with pixels addressible up to 720 by 348
  305.             and characters up to 90 by 29.
  306.  
  307.           - _M_o_d_e _9 - _H_e_r_c_u_l_e_s _g_r_a_p_h_i_c_s _m_o_d_e, with closely-spaced
  308.             characters. This uses the full Hercules raster, with pixels
  309.             addressible up to 720 by 348 and characters up to 90 by 43.
  310.  
  311.        I chose 8 and 9 for the Hercules modes because they seem unlikely
  312.        to conflict with other modes on a machine equipped with a
  313.        Hercules board. (Other displays that use modes 8 and 9 are the
  314.        PCJr and the Tandy 1000.) However, if you wish to reassign the
  315.        Hercules modes to some other values, use the /M option when you
  316.        install HERCBIOS. Two hex digits must follow the /M; they are the
  317.        mode (in hexadecimal) for Hercules graphics with 29 rows of
  318.        characters. The 43-row Hercules mode is one greater than the
  319.        29-row mode. For instance, the option /_M_6_D makes mode 6D (hex)
  320.        the 29-row mode and mode 6E the 43-row mode.
  321.  
  322.  
  323.        _3._2. _B_I_O_S _F_u_n_c_t_i_o_n_s
  324.  
  325.        The functions implemented by HERCBIOS are:
  326.  
  327.        HERCBIOS 2.1                                             10-31-88
  328.  
  329.  
  330.  
  331.  
  332.  
  333.                                      - 6 -
  334.  
  335.  
  336.                Fn  0 - Set mode (4, 5, 6, 7, 8, or 9)
  337.  
  338.                Fn  2 - Set cursor position
  339.                Fn  3 - Read cursor position
  340.                Fn  5 - New display page
  341.                Fn  6 - Scroll up
  342.                Fn  7 - Scroll down
  343.                Fn  9 - Write character with attribute
  344.                Fn 10 - Write character
  345.                Fn 12 - Write pixel
  346.                Fn 13 - Read pixel
  347.                Fn 14 - Teletypewriter-style character write
  348.                Fn 15 - Get video status
  349.  
  350.        Check your System Programmers' Guide for the use of these BIOS
  351.        functions. HERCBIOS implements these functions faithfully, with
  352.        the following known specializations and exceptions:
  353.  
  354.           - The Hercules board has enough RAM for two pages in graphics
  355.             mode, so HERCBIOS supports pages 0 and 1.
  356.  
  357.           - Since attributes aren't stored in video RAM, we have to
  358.             cheat a little. The scrolling functions (6 and 7), in
  359.             setting the attribute for the "fill" lines, set pixels ON if
  360.             the attribute is 70 hex (reverse video) and OFF otherwise.
  361.  
  362.           - For similar reasons, the "write character without
  363.             attribute" function (10) writes all characters using the
  364.             "normal" attribute, since it has no way of knowing the
  365.             present attribute. The "write character and attribute
  366.             function" (9) tries to mimic the behavior of character mode,
  367.             as detailed below.
  368.  
  369.           - The Teletypewriter-style character write function (14)
  370.             ignores BL, since foreground color is meaningless on a
  371.             Hercules board.
  372.  
  373.  
  374.        When you use HERCBIOS to draw characters on the screen, remember
  375.        that a number of properties of the alphanumeric display are not
  376.        supported by the hardware when you enter graphics mode. For
  377.        instance, the cursor is not shown in graphics mode, and the
  378.        character attributes are not supported by the hardware. HERCBIOS
  379.        does its best to emulate the alphanumeric mode, but it cannot
  380.        implement a cursor or the blinking or bold attributes. The table
  381.        below shows the "best shot" that HERCBIOS takes at character
  382.        attributes:
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.        HERCBIOS 2.1                                             10-31-88
  394.  
  395.  
  396.  
  397.  
  398.  
  399.                                      - 7 -
  400.  
  401.  
  402.                _C_O_D_E    _U_S_U_A_L_L_Y _M_E_A_N_S      _H_E_R_C-_4_3 _M_O_D_E    _H_E_R_C-_2_9 _M_O_D_E
  403.                00      invisible          invisible       invisible
  404.                01      underline          [normal]        underline
  405.                07      normal             normal          normal
  406.                0F      hi-intens          [rev video]     [rev video]
  407.                70      rev video          rev video       rev video
  408.  
  409.  
  410.                Anything else displays as normal
  411.  
  412.  
  413.        _3._3. _W_h_a_t _L_a_n_g_u_a_g_e_s _W_o_r_k?
  414.  
  415.        I have written programs using HERCBIOS in a number of languages.
  416.        Here are some of the caveats I'd like to pass on:
  417.  
  418.           - Things are fine using INT 10h calls in assembler.  (No big
  419.             surprise.)
  420.  
  421.           - Similarly, programs written in a higher-level langauge that
  422.             have BIOS function calls (e.g.- "int86" in Turbo C and
  423.             Microsoft C) can make use of these BIOS routines. The
  424.             TESTPIX program included in this distribution is an example.
  425.  
  426.           - Microsoft's BASICA and GWBASIC work in CGA emulation mode.
  427.             That means that you can write programs that call the
  428.             graphics screens, or run existing graphics programs from the
  429.             BASIC interpreter.
  430.  
  431.           - Any language that writes to the standard output hangs the
  432.             machine if it triggers a scroll by writing off the bottom of
  433.             the screen; so do DOS and COMMAND.COM. This problem does not
  434.             arise with programs that use BIOS function 14 (TTY write) to
  435.             write off the bottom of the screen.
  436.  
  437.             A significant example is the typical C compiler writing to
  438.             stdout; the behavior has been confirmed with Turbo C
  439.             (Version 1.0). Of course, you can write your own utility
  440.             functions to write to the screen using HERCBIOS functions.
  441.             The sample program packed with HERCBIOS includes HERCPIXL, a
  442.             one-file C "library" of such utilities.
  443.  
  444.           - Borland's Turbo Pascal (Versions 1 and 2) behaves a bit
  445.             strangely when writing to the screen using the usual
  446.             functions (gotoxy, write, writeln). It works just fine,
  447.             except that it won't move the cursor out of the 80 x 25
  448.             character screen it knows about. (I haven't tested HERCBIOS
  449.             with more recent releases of Turbo Pascal.)
  450.  
  451.           - The TESTPIX program was originally written in deSmet C 2.4.
  452.             It worked fine, with one caveat. The console I/O routine
  453.             _g_e_t_c_h_a_r() seems to write to display memory (perhaps as part
  454.             of keyboard echo). This can interfere with what is displayed
  455.             on the Hercules board display page 1.  (I had no problems on
  456.             page 0.)
  457.  
  458.  
  459.        HERCBIOS 2.1                                             10-31-88
  460.  
  461.  
  462.  
  463.  
  464.  
  465.                                      - 8 -
  466.  
  467.  
  468.        _R_E_G_I_S_T_R_A_T_I_O_N _A_N_D _C_O_P_Y_I_N_G
  469.  
  470.        HERCBIOS is not in the public domain; it is shareware. It is
  471.        copyrighted by David M. Tutelman, who reserves all rights to the
  472.        program. You are permitted to use the program, with the following
  473.        restrictions.
  474.  
  475.          _R_e_g_i_s_t_r_a_t_i_o_n:
  476.             If you find HERCBIOS useful, you are requested to register
  477.             your copy. The registration fee is $15. It entitles you to a
  478.             copy of the source code and the most recent distribution
  479.             version.
  480.  
  481.             If you use HERCBIOS in your work, registration is mandatory,
  482.             not optional.
  483.  
  484.          _C_o_p_y_i_n_g _a_n_d _D_i_s_t_r_i_b_u_t_i_o_n:
  485.             You may make copies of HERCBIOS for your own use.
  486.  
  487.             You may distribute copies of HERCBIOS provided that:
  488.                - All the files in the original distribution are
  489.                  included, unmodified and with their original names.
  490.                - No charge is made for the copy, above the actual cost
  491.                  of media, packaging material, and postage or
  492.                  communication charges.
  493.  
  494.             You must have written permission from the author to make any
  495.             additional charge (for instance, a handling charge for your
  496.             labor, any charge to cover your inventory or overhead
  497.             expenses, or profit.) The author intends to be fairly
  498.             liberal in granting such permission, but asserts the right
  499.             to control commercial or semi-commercial distribution of his
  500.             work.
  501.  
  502.             You may distribute HERCBIOS as part of a software package,
  503.             collection, or compilation, only if all the above
  504.             requirements are met for the package as a whole, and if no
  505.             compilation copyright is claimed on the collection.
  506.  
  507.             You may not distribute modified versions or derivative works
  508.             of HERCBIOS without written permission from the HERCBIOS
  509.             author.
  510.  
  511.        If you wish an exception from any provision of this license,
  512.        contact the author for written permission.
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.        HERCBIOS 2.1                                             10-31-88
  526.  
  527.  
  528.  
  529.  
  530.  
  531.                                      - 9 -
  532.  
  533.  
  534.        _R_E_L_E_A_S_E _H_I_S_T_O_R_Y _O_F _H_E_R_C_B_I_O_S
  535.  
  536.  
  537.        1.X     1984 through 1986
  538.                HERCBIOS had BIOS functions only.  At least two postings
  539.                were made to USENET, and it found its way to various
  540.                bulletin boards.  Some BB versions were corrupted (i.e. -
  541.                missing files).
  542.  
  543.  
  544.        2.0     8/88
  545.                Emulation capability added in November '86.
  546.                HERCBIOS "repackaged" to include emulation in summer '88,
  547.                and called HERCBIOS 2.0.
  548.  
  549.  
  550.        2.1     10/88  Bugfix Release
  551.                Character count in CX on Functions 9 & 10 fixed.
  552.                Graphic character table in INT 1F fixed.
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.        HERCBIOS 2.1                                             10-31-88
  592.  
  593.  
  594.  
  595.